home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mint110s / inline.h < prev    next >
C/C++ Source or Header  |  1994-02-11  |  2KB  |  96 lines

  1. /*
  2. Copyright 1992 Eric R. Smith.
  3. Copyright 1993 Atari Corporation.
  4. All rights reserved.
  5.  */
  6.  
  7. /*
  8.  * inlining of various utility functions, for speed
  9.  * NOTE: ALL functions in this file must also have
  10.  * "normal" equivalents in the .c or .s files;
  11.  * don't put a function just into here!
  12.  */
  13.  
  14. #ifdef __GNUC__
  15.  
  16. #define spl7()            \
  17. ({  register short retvalue;    \
  18.     __asm__ volatile("        \
  19.     movew sr,%0;         \
  20.     oriw  #0x0700,sr "     \
  21.     : "=d"(retvalue)         \
  22.     ); retvalue; })
  23.  
  24. #define spl(N)            \
  25. ({                  \
  26.     __asm__ volatile("        \
  27.     movew %0,sr "         \
  28.     :                \
  29.     : "d"(N) ); })
  30.  
  31.  
  32. /*
  33.  * note that we must save some registers ourselves,
  34.  * or else gcc will run out of reggies to use
  35.  * and complain
  36.  */
  37.  
  38. /* On TOS 1.04, when calling Bconout(2,'\a') the VDI jumps directly
  39.    back to the BIOS which expects the register A5 to be set to zero.
  40.    (Specifying the register as clobbered does not work.) */
  41.  
  42. #define callout1(func, a)            \
  43. ({                        \
  44.     register long retvalue __asm__("d0");    \
  45.     long _f = func;                \
  46.     short _a = (short)(a);            \
  47.                         \
  48.     __asm__ volatile            \
  49.     ("  moveml d5-d7/a4-a6,sp@-;        \
  50.         movew %2,sp@-;            \
  51.         movel %1,a0;            \
  52.         subal a5,a5;            \
  53.         jsr a0@;                \
  54.         addqw #2,sp;            \
  55.         moveml sp@+,d5-d7/a4-a6 "        \
  56.     : "=r"(retvalue)    /* outputs */    \
  57.     : "r"(_f), "r"(_a)    /* inputs */    \
  58.     : "d0", "d1", "d2", "d3", "d4",        \
  59.       "a0", "a1", "a2", "a3" /* clobbered regs */ \
  60.     );                    \
  61.     retvalue;                \
  62. })
  63.  
  64.  
  65. #define callout2(func, a, b)            \
  66. ({                        \
  67.     register long retvalue __asm__("d0");    \
  68.     long _f = func;                \
  69.     short _a = (short)(a);            \
  70.     short _b = (short)(b);            \
  71.                         \
  72.     __asm__ volatile            \
  73.     ("  moveml d5-d7/a4-a6,sp@-;        \
  74.         movew %3,sp@-;            \
  75.         movew %2,sp@-;            \
  76.         movel %1,a0;
  77.         subal a5,a5;            \
  78.         jsr a0@;                \
  79.         addqw #4,sp;            \
  80.         moveml sp@+,d5-d7/a4-a6 "        \
  81.     : "=r"(retvalue)    /* outputs */    \
  82.     : "r"(_f), "r"(_a), "r"(_b) /* inputs */ \
  83.     : "d0", "d1", "d2", "d3", "d4",        \
  84.       "a0", "a1", "a2", "a3" /* clobbered regs */ \
  85.     );                    \
  86.     retvalue;                \
  87. })
  88.  
  89. #define flush_pmmu() __asm__ volatile("pflusha");
  90. #endif
  91.  
  92. #ifdef LATTICE
  93. #pragma inline d0=spl7()    {"40c0007c0700";}
  94. #pragma inline d0=spl(d0)    {"46c0";}
  95. #endif
  96.